//
//  RMMSelectLocationView.m
//  Romomo
//
//  Created by puman on 2016/12/16.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMSelectLocationView.h"

@implementation RMMSelectLocationView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self =  [super initWithFrame:frame]) {
        _backView = [[UIView alloc] initWithFrame:self.bounds];
        _backView.alpha = 0.0;
        _backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        [self addSubview:_backView];
        
        UIButton *buttons = [UIButton buttonWithType:(UIButtonTypeCustom)];
        buttons.frame = CGRectMake(0, 0, kScreenWideth, _backView.height - 249);
        BUTTON_S(buttons, cancel);
        [_backView addSubview:buttons];
        
        _view =  [[UIView alloc] initWithFrame:CGRectMake(0, self.height, self.width, 249)];
        _view.backgroundColor = kWhiteColor;
        [self addSubview:_view];
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWideth, 49)];
        view.backgroundColor = RGBA(248, 249, 250, 1);
        [_view addSubview:view];
        NSArray *arr = @[@"取消",@"确定"];
        for (int i = 0; i < 2; i++) {
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
            button.frame = CGRectMake((kScreenWideth - 60) *i, 0, 60, 49);
            [button setTitle:arr[i] forState:(UIControlStateNormal)];
            [button setTitleColor:RGBA(44, 113, 212, 1) forState:(UIControlStateNormal)];
            button.titleLabel.font = kFont(14);
            [view addSubview:button];
            switch (i) {
                case 0:
                    _leftBut = button;
                    BUTTON_S(_leftBut, cancel);
                    break;
                case 1:
                    _rihthBut = button;
                    break;
                    
                    
                default:
                    break;
            }
        }
        _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 49, kScreenWideth, _view.height - 49)];
        [_view addSubview:_pickerView];
    }
    return self;
}
- (void)cancel{
    [UIView animateWithDuration:kInterval animations:^{
        _view.frame = CGRectMake(0, self.height, kScreenWideth, 249);
        _backView.alpha = 0.0;
    } completion:^(BOOL finished) {
        self.hidden = YES;
    }]; 
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
